/*
Copyright (c) [2019年5月1日] [吴超]
[MBT_studio] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
		 http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/
#include "ui大纲视图.h"



#include "框架/工作区/工作区.h"
#include "物体编辑/物体编辑.h"
#include "物体管理/渲染物体管理.h"

#include <Context/当前默认操作数据.h>


std::set<C_大纲视图*> C_大纲视图::g大纲视图;




static void f_树形框项布局(C_Widget* self, C_Widget** w, uint32 num) {
	S_Object* item = (S_Object*)self->m_UserData;

	float32 组件大小 = self->m_Size.y;
	for (uint32 i = 0; i < num; ++i) {
		w[i]->f_setSize({ 组件大小, 组件大小 });
	}
	
	if (item) {
		if (item->m_是否展开) {
			w[0]->m_ICO = u"下";
		}
		else {
			w[0]->m_ICO = u"播放";
		}

		switch (item->m_Type) {
			case E_物体类型::t_网格物体:
			case E_物体类型::t_多边形:
				w[1]->m_ICO = u"物体";
				break;
			case E_物体类型::t_网格缓存:
				w[1]->m_ICO = u"四边顶点";
				break;
			case E_物体类型::t_虚拟体:
				w[1]->m_ICO = u"立体线框";
				break;
			case E_物体类型::t_摄像机:
				w[1]->m_ICO = u"font-449";
				break;
			case E_物体类型::t_物理体:
				w[1]->m_ICO = u"planet32";
				break;

			case E_物体类型::t_渲染世界:
				w[1]->m_ICO = u"世界";
				break;
			case E_物体类型::t_渲染层:
				w[1]->m_ICO = u"layers_1";
				break;
			case E_物体类型::t_渲染物体:
				w[1]->m_ICO = u"物体";
				break;
			case E_物体类型::t_场景节点: 
			case E_物体类型::t_物体节点: {
				w[1]->m_ICO = u"节点";
				break;
			}
			default:
				w[1]->m_ICO = u"包";
				break;
		}


		uint32 按钮数量 = 4;
		switch (item->m_Type) {
			case E_物体类型::t_虚拟体:
			case E_物体类型::t_网格物体:
			case E_物体类型::t_多边形:
				w[3]->m_ICO = item->m_显示 ? u"可视" : u"";
				w[4]->m_ICO = item->m_可拾取 ? u"选择" : u"空选择";
				break;
			case E_物体类型::t_网格缓存:
				w[3]->m_ICO = u"";
				break;

			case E_物体类型::t_渲染世界:
				w[3]->m_ICO = item->m_显示 ? u"加" : u"加";
				w[4]->m_ICO = item->m_显示 ? u"减" : u"减";
				break;

			case E_物体类型::t_渲染层: {
				按钮数量 = 2;
				break;
			}
			case E_物体类型::t_渲染物体: {
				//w[3]->f_setSize({ 组件大小 * 8, 组件大小 });
				//w[4]->f_setSize({ 组件大小 * 8, 组件大小 });
				break;
			}
			case E_物体类型::t_场景节点: {
				按钮数量 = 4;
				w[2]->m_ICO = item->m_显示 ? u"可视" : u"";
				w[3]->m_ICO = item->m_显示 ? u"选择" : u"";
				break;
			}
			
			default:
				//w[3]->m_ICO = u"";
				//w[4]->m_ICO = u"";
				break;
		}


		w[2]->m_WName = item->m_Name;


		float32 推进 = item->m_层深度 * self->m_Size.y;
		vec2 大小 = { self->m_Size.x, self->m_Size.y };
		大小.x = max(self->m_Size.y * 按钮数量 + 推进, 大小.x);

		f_HBOX布局({ 推进,0 }, 大小, w, num);
	}
	else {
		self->m_ICO = u"下";
	}
}

static E_事件是否传递 on_展开按钮点击(C_Widget* self, const E_鼠标按钮& 按钮) {
	S_Object* item = (S_Object*)(self->m_父部件->m_UserData);
	if (item) {
		if (item->m_是否展开) {
			item->m_是否展开 = false;
		}
		else {
			item->m_是否展开 = true;
		}
	}
	

	f_ui_树形框_构建区域项显示(self->m_父部件->m_父部件);
	//self->m_父部件->m_父部件->m_更新绘制属性 = true;
	f_widget_更新绘制(self->m_父部件->m_父部件->m_父部件);
	return E_事件是否传递::e_事件传递_终止;
}

static E_事件是否传递 on_对象面板点击(C_Widget* self, const E_鼠标按钮& 按钮) {
	C_大纲视图* view = static_cast<C_大纲视图*>(self->m_父部件->m_父部件->m_父部件);
	S_Object* item = (S_Object*)(self->m_父部件->m_UserData);

	switch (item->m_Type) {
		case E_物体类型::t_渲染世界: {
			f_大纲视图_重构渲染世界属性栏(view->m_属性栏, { item });
			break;
		}
		case E_物体类型::t_渲染层: {
			f_大纲视图_重构渲染层属性栏(view->m_属性栏, { item });
			break;
		}
		case E_物体类型::t_渲染物体: {
			f_大纲视图_重构渲染物体属性栏(view->m_属性栏, { item });
			break;
		}
		default: {
			//S_物体* ob = dynamic_cast<S_物体*>(item);
			//if (ob) {
			//	f_om_设置拾取物体({ob}, false, E_工作区类型::e_大纲视口);
			//}
			break;
		}
	}
	
	
	//f_ui_树形框_清楚选择项(self->m_父部件->m_父部件);
	f_ui_树形框_设置区间选择项(self->m_父部件->m_父部件, self->m_父部件, &item, 1);
	std::vector<S_Object*> si = f_ui_树形框_取选择项(self->m_父部件->m_父部件);
	std::set<S_物体*> 过滤对象;
	for (auto& e : si) {
		switch (e->m_Type) {
			case E_物体类型::t_多边形: 
			case E_物体类型::t_网格物体: {
				过滤对象.insert(static_cast<S_物体*>(e));
				break;
			}
			default:
				break;
		}
	}
	f_om_设置拾取物体(过滤对象, false, E_工作区类型::e_大纲视口);

	
	self->m_父部件->m_颜色A = S_UI主题::uic_焦点色;
	self->m_父部件->m_父部件->m_更新绘制属性 = true;

	f_工作区_联动更新(E_工作区类型::e_大纲视口, E_工作区操作类型::e_拾取物体);
	return E_事件是否传递::e_事件传递_终止;
}

static E_事件是否传递 on_显示按钮点击(C_Widget* self, const E_鼠标按钮& 按钮) {
	S_Object& item = *(S_Object*)(self->m_父部件->m_UserData);
	if (item.m_显示) {
		item.m_显示 = false;
		self->m_ICO = u"隐藏";
	}
	else {
		item.m_显示 = true;
		self->m_ICO = u"眼睛";
	}

	//self->m_父部件->m_父部件->m_更新绘制属性 = true;
	f_widget_更新绘制(self->m_父部件->m_父部件);
	//f_widget_重构渲染层(self->m_父部件->m_父部件->m_父部件->m_父部件);
	f_工作区_联动更新(E_工作区类型::e_大纲视口, E_工作区操作类型::e_拾取物体);
	return E_事件是否传递::e_事件传递_终止;
}

static E_事件是否传递 on_选择按钮点击(C_Widget* self, const E_鼠标按钮& 按钮) {
	S_Object& item = *(S_Object*)(self->m_父部件->m_UserData);
	if (item.m_可拾取) {
		item.m_可拾取 = false;
		self->m_ICO = u"空选择";
	}
	else {
		item.m_可拾取 = true;
		self->m_ICO = u"选择";
	}

	self->m_父部件->m_父部件->m_更新绘制属性 = true;
	return E_事件是否传递::e_事件传递_终止;
}



static E_事件是否传递 on_添加渲染层_按钮点击(C_Widget* self, const E_鼠标按钮& 按钮) {
	S_Object* item = (S_Object*)(self->m_父部件->m_UserData);
	C_大纲视图* view = static_cast<C_大纲视图*>(self->m_父部件->m_父部件->m_父部件);

	switch (item->m_Type) {
		case E_物体类型::t_渲染世界: {
			S_Object* 渲染层 = f_node_创建渲染层(item, u"新渲染层", *S_节点框架::g_3D视口环境);

			f_world_添加渲染层((S_渲染世界*)item->m_UserData, (S_渲染层*)渲染层->m_UserData, 渲染层->m_ID);
			view->m_更新绘制属性 = true;
			
			f_大纲视图_重构渲染层属性栏(view->m_属性栏, { 渲染层 });
			break;
		}
		default:
			break;
	}
	
	self->m_父部件->m_父部件->m_更新绘制属性 = true;
	return E_事件是否传递::e_事件传递_终止;
}

static E_事件是否传递 on_删除渲染层_按钮点击(C_Widget* self, const E_鼠标按钮& 按钮) {
	S_Object* item = (S_Object*)(self->m_父部件->m_UserData);
	C_大纲视图* view = static_cast<C_大纲视图*>(self->m_父部件->m_父部件);


	auto obs = f_ui_树形框_取选择项(view->f_get子组件(0));
	for (auto& e : obs) {
		switch (e->m_Type) {
			case E_物体类型::t_渲染层: {
				
				f_node_删除渲染层(item, e->m_Name);
				view->m_更新绘制属性 = true;
				break;
			}
		}
	}
	f_大纲视图_重构渲染层属性栏(view->m_属性栏, { });

	self->m_父部件->m_父部件->m_更新绘制属性 = true;
	return E_事件是否传递::e_事件传递_终止;
}

static E_事件是否传递 on_开关场景节点_按钮点击(C_Widget* self, const E_鼠标按钮& 按钮) {
	S_Object* item = (S_Object*)(self->m_父部件->m_UserData);
	C_大纲视图* view = static_cast<C_大纲视图*>(self->m_父部件->m_父部件->m_父部件);

	switch (item->m_Type) {
		case E_物体类型::t_场景节点: {
			
			break;
		}
		default:
			break;
	}

	self->m_父部件->m_父部件->m_更新绘制属性 = true;
	return E_事件是否传递::e_事件传递_终止;
}



static void on_树形框项绘制信息(C_Widget* itemWidget, uint32 列) {
	S_Object* item = (S_Object*)itemWidget->m_UserData;

}

uint32 on_计算树形框项显示层级(S_Object* item, int32 缩减, int32& 行开始偏移, C_Widget** w, uint32 num, uint32& index) {
	uint32 层数 =0;

	uint32 层数量 = 0;
	switch (item->m_Type) {
		case E_物体类型::t_虚拟体:
		case E_物体类型::t_多边形:
		case E_物体类型::t_网格物体: {
			S_物体* ob = static_cast<S_物体*>(item);
			
			if (ob->m_扩展属性[0]) {
				int32 累计项 = f_ui_树形框_层级组件步进(ob->m_扩展属性[0], 行开始偏移, w, num, index);
				if (累计项) {
					层数量 += on_计算树形框项显示层级(ob->m_扩展属性[0], 缩减, 行开始偏移, w, num, index);
					
				}
				层数量 = 1;
				item->m_层深度 = 缩减;
			}
			
			break;
		}

		case E_物体类型::t_网格缓存: {
			//层数量 = 1;
			//item->m_层深度 = 缩减;
			break;
		}
		case E_物体类型::t_物体节点: {
			//层数量 = 1;
			item->m_层深度 = 缩减;
			break;
		}
		case E_物体类型::t_场景节点: {
			//层数量 = 1;
			item->m_层深度 = 缩减;
			break;
		}
		default:
			break;
	}

	if (item->m_是否展开) {
		层数 += 层数量;
	}
	return 层数;
}


void on_树形框创建项附件组件(S_UI渲染环境& ctx, C_Widget* self) {
	uint32 已有数量 = self->f_get子部件数量();

	S_Object* item = (S_Object*)self->m_UserData;
	switch (item->m_Type) {
		case E_物体类型::t_渲染层:
		case E_物体类型::t_渲染世界: {
			return;
		}
		default: {
			if(已有数量 == 5) return;
			break;
		}
	}
	f_widget_remove所有子部件(self, false);

	C_Widget* 展开按钮 = f_ui_创建组件();
	C_Widget* 对象面板 = f_ui_创建组件();
	C_Widget* 信息条 = f_ui_创建组件();
	C_Widget* 显示按钮 = f_ui_创建组件();
	C_Widget* 选择按钮 = f_ui_创建组件();
	//C_Widget* 选择按钮 = new C_Widget;

	展开按钮->m_ICO = u"播放";
	展开按钮->m_图标大小 = 8;

	对象面板->m_ICO = u"物体";
	对象面板->m_图标大小 = 16;

	显示按钮->m_ICO = u"眼睛";
	显示按钮->m_图标大小 = 16;

	选择按钮->m_ICO = u"选择";
	选择按钮->m_图标大小 = 16;

	展开按钮->m_是否延展 = { false, true };
	对象面板->m_是否延展 = { false, true };
	信息条->m_是否延展 = { true, true };
	显示按钮->m_是否延展 = { false, true };
	选择按钮->m_是否延展 = { false, true };

	self->f_添加子组件(展开按钮);
	self->f_添加子组件(对象面板);
	self->f_添加子组件(信息条);
	self->f_添加子组件(显示按钮);
	self->f_添加子组件(选择按钮);
	//item->f_添加子组件(展开按钮);

	self->mf_布局 = f_树形框项布局;
	

	展开按钮->mf_鼠标点击 = on_展开按钮点击;
	对象面板->mf_鼠标点击 = on_对象面板点击;
	信息条->mf_鼠标点击 = on_对象面板点击;
	显示按钮->mf_鼠标点击 = on_显示按钮点击;
	选择按钮->mf_鼠标点击 = on_选择按钮点击;
}

void on_树形框_渲染层_创建项附件组件(S_UI渲染环境& ctx, C_Widget* self) {
	//if(self->f_get子部件数量() > 2) return;
	uint32 已有数量 = self->f_get子部件数量();

	S_Object* item = (S_Object*)self->m_UserData;

	switch (item->m_Type) {
		case E_物体类型::t_渲染层: {
			if(已有数量 == 3) return;
			break;
		}
		case E_物体类型::t_渲染世界: {
			if (已有数量 == 5) return;
			break;
		}
		case E_物体类型::t_渲染物体: {
			if (已有数量 == 3) return;
			break;
		}
		default: {
			if (已有数量 == 5) return;
			break;
		}
	}
	f_widget_remove所有子部件(self, false);


	C_Widget* 展开按钮 = f_ui_创建组件();
	C_Widget* 对象面板 = f_ui_创建组件();
	C_Widget* 信息条 = f_ui_创建组件();
	

	展开按钮->m_ICO = u"播放";
	展开按钮->m_图标大小 = 10;

	对象面板->m_ICO = u"物体";
	对象面板->m_图标大小 = 16;

	

	展开按钮->m_是否延展 = { false, true };
	对象面板->m_是否延展 = { false, true };
	信息条->m_是否延展 = { true, true };
	

	self->f_添加子组件(展开按钮);
	self->f_添加子组件(对象面板);
	self->f_添加子组件(信息条);
	self->mf_布局 = f_树形框项布局;


	展开按钮->mf_鼠标点击 = on_展开按钮点击;
	对象面板->mf_鼠标点击 = on_对象面板点击;
	信息条->mf_鼠标点击 = on_对象面板点击;
	
	switch (item->m_Type) {
		case E_物体类型::t_渲染层: {
			break;
		}
		case E_物体类型::t_渲染物体: {
			S_渲染对象* renderOb = dynamic_cast<S_渲染对象*>(item);
			
			break;
		}
		default: {
			C_Widget* 添加层按钮 = f_ui_创建组件();
			C_Widget* 删除层按钮 = f_ui_创建组件();

			添加层按钮->m_ICO = u"加";
			添加层按钮->m_图标大小 = 16;

			删除层按钮->m_ICO = u"减";
			删除层按钮->m_图标大小 = 16;

			添加层按钮->m_是否延展 = { false, true };
			删除层按钮->m_是否延展 = { false, true };

			添加层按钮->mf_鼠标点击 = on_添加渲染层_按钮点击;
			删除层按钮->mf_鼠标点击 = on_删除渲染层_按钮点击;

			self->f_添加子组件(添加层按钮);
			self->f_添加子组件(删除层按钮);
			break;
		}
	}

}

void on_大纲视图_创建项附件组件_场景节点树(S_UI渲染环境& ctx, C_Widget* self) {
	uint32 已有数量 = self->f_get子部件数量();

	S_Object* item = (S_Object*)self->m_UserData;

	switch (item->m_Type) {
		case E_物体类型::t_场景节点: {
			if(已有数量 == 4) return;
			break;
		}
		default: {
			if (已有数量 == 4) return;
			break;
		}
	}
	f_widget_remove所有子部件(self, false);


	C_Widget* 展开按钮 = f_ui_创建组件();
	C_Widget* 对象面板 = f_ui_创建组件();
	C_Widget* 信息条 = f_ui_创建组件();


	展开按钮->m_ICO = u"播放";
	展开按钮->m_图标大小 = 10;

	对象面板->m_ICO = u"节点";
	对象面板->m_图标大小 = 16;

	展开按钮->m_是否延展 = { false, true };
	对象面板->m_是否延展 = { false, true };
	信息条->m_是否延展 = { true, true };


	self->f_添加子组件(展开按钮);
	self->f_添加子组件(对象面板);
	self->f_添加子组件(信息条);
	self->mf_布局 = f_树形框项布局;


	展开按钮->mf_鼠标点击 = on_展开按钮点击;
	对象面板->mf_鼠标点击 = on_对象面板点击;
	信息条->mf_鼠标点击 = on_对象面板点击;

	switch (item->m_Type) {
		case E_物体类型::t_场景节点: {
			C_Widget* 运行按钮 = f_ui_创建组件();
			C_Widget* 渲染按钮 = f_ui_创建组件();

			运行按钮->m_ICO = u"加";
			运行按钮->m_图标大小 = 16;
			运行按钮->m_是否延展 = { false, true };
			运行按钮->mf_鼠标点击 = on_开关场景节点_按钮点击;

			渲染按钮->m_ICO = u"加";
			渲染按钮->m_图标大小 = 16;
			渲染按钮->m_是否延展 = { false, true };
			渲染按钮->mf_鼠标点击 = on_开关场景节点_按钮点击;

			self->f_添加子组件(运行按钮);
			self->f_添加子组件(渲染按钮);
			break;
		}
		default: {
			
			break;
		}
	}
}


void on_树形框项附件组件重置(C_Widget* self) {
	
}


static E_事件是否传递 f_大纲视图_树形框鼠标滚轮(C_Widget* self, const S_鼠标& 鼠标) {
	auto& view = *self->f_get子组件(0);
	auto* 滚动条 = self->f_get子组件(1);

	f_布局_纵向滚动值限度(view.m_Pos.y, self->m_Size.y, view.m_Size.y, C_Widget::g_鼠标.lZ * 40);
	f_ui_树形框_构建区域项显示(&view);
	f_widget_更新绘制(self);

	f_ui_滚动条更新属性(滚动条);
	f_widget_更新绘制(self);

	return E_事件是否传递::e_事件传递_终止;
}

static void f_大纲视图布局(C_Widget* self, C_Widget** w, uint32 num) {
	auto ui_tree = w[0];
	auto ui_roll = w[1];

	vec2 size = self->m_Size;
	size.x -= ui_roll->m_Size.x;

	ui_tree->f_setSize(size);
	float32 内部高度 = f_ui_树形框_构建区域项显示(ui_tree);

	//size.x = S_UI主题::ui_拖拽手柄宽度;
	f_布局_纵向滚动条(ui_roll, self->m_Size, 2, 内部高度);
}
static void f_大纲视图绘制(C_Widget* self, S_2D画布* 画布) {
	C_大纲视图& box = *dynamic_cast<C_大纲视图*>(self);
	box.m_背景 = f_vg_genConvex((*self), *画布, E_填充模式::e_填充面, E_图层混合模式::e_Normal);

}
static void f_大纲视图变换(C_Widget* self) {
	C_大纲视图& box = *dynamic_cast<C_大纲视图*>(self);
	float32 dpi = box.m_UIctx->m_DPI;

	auto ui_tree = self->f_get子组件(0);
	auto 滚动条 = self->f_get子组件(1);

	std::vector<S_2DConvexRect>	区域(1);
	std::vector<S_GPU内存块*>	形状(1);
	std::vector<S_2D颜色包>		颜色(1);
	std::vector<vec2>			位置(1);

	f_ui_draw_temple_树形框(ui_tree, 区域[0], 颜色[0]);
	形状[0] = &(box.m_UIctx->m_Ctx.m_几何图形->m_平面矩形);

	//bool 手柄展开 = ui_roll->m_ColorA.m_颜色.a != S_UI主题::uic_拖拽手柄.a;
	//f_ui_draw_temple_拖放条手柄(ui_roll, 区域, 形状, 颜色, 位置, 手柄展开);
	S_2DConvexRect rect{};
	vec2 pos = 滚动条->m_Pos;
	rect.size = 滚动条->m_Size;
	
	rect.radius.x = min(dpi*5, rect.size.x);
	rect.radius.y = rect.radius.x;

	形状.push_back(&(box.m_UIctx->m_Ctx.m_几何图形->m_平面圆角矩形));
	区域.push_back(rect);
	颜色.push_back(S_2D颜色包(S_UI主题::uic_滚动条));
	位置.push_back(pos);

	滚动条 = 滚动条->f_get子组件(0);

	rect.size = 滚动条->m_Size;
	if (滚动条->m_ColorA.m_颜色.a < 255) {
		rect.size -= rect.size.x * 0.6;
		pos += (滚动条->m_Size - rect.size) * 0.5;

		rect.radius.x = min(dpi*5, rect.size.x);
		rect.radius.y = rect.radius.x;
	}
	形状.push_back(&(box.m_UIctx->m_Ctx.m_几何图形->m_平面圆角矩形));
	区域.push_back(rect);
	颜色.push_back(滚动条->m_ColorA);
	位置.push_back(pos + 滚动条->m_Pos);


	f_vg_tranform(*box.m_背景, 位置.size(), 位置.data());
	f_vg_drawConvex(*box.m_背景, 形状.size(), 形状.data(), 区域.data());
	f_vg_color(*box.m_背景, 颜色.size(), 颜色.data());
}

C_大纲视图::C_大纲视图(S_UI渲染环境& ctx) : C_Widget(&ctx) {
	f_widget_添加绘制画布(this);

	m_树形框 = f_ui_树形框_创建(ctx, f_global_大纲数据());
	auto* 滚动条 = f_ui_创建滚动条(ctx, E_方向::e_纵向);

	f_ui_树形框_绑定回调函数(m_树形框, f_global_大纲数据(), on_计算树形框项显示层级, on_树形框创建项附件组件);
	f_ui_滚动条绑定属性(滚动条, &m_树形框->m_Pos.y, m_树形框->m_Size.y);

	f_添加子组件(m_树形框);
	f_添加子组件(滚动条);

	g大纲视图.insert(this);
	m_当前视图内容 = 0;
}

C_大纲视图::~C_大纲视图() {
	g大纲视图.erase(this);
}


C_大纲视图* f_大纲视图_创建(S_UI渲染环境& ctx) {
	C_大纲视图* box = new C_大纲视图(ctx);
	box->m_属性栏 = f_创建属性边栏(ctx);
	box->m_状态条 = new C_状态条(ctx);

	box->mf_布局		= f_大纲视图布局;
	box->mf_绘制		= f_大纲视图绘制;
	box->mf_变换		= f_大纲视图变换;
	box->mf_鼠标滚轮	= f_大纲视图_树形框鼠标滚轮;

	return box;
}





void f_大纲视图_重构渲染世界属性栏(C_属性栏* plane, const std::set<S_Object*>& items) {
	std::vector<S_Props> props;

	if (items.size() == 1) {
		S_Object* item = *items.begin();
		//auto 通道遮罩 = f_alloc_FB8_EnumProp(&(((S_渲染世界*)item->m_UserData)->m_Maks), u"层通道");
		//props.push_back(通道遮罩);
	}
	else {

	}

	plane->f_构建属性部件(props);
}

void f_大纲视图_重构渲染层属性栏(C_属性栏* plane, const std::set<S_Object*>& items) {
	std::vector<S_Props> props;

	if (items.size() == 1) {
		S_Object* item = *items.begin();
		//auto 通道遮罩 = f_alloc_FB8_EnumProp(&(((S_渲染层*)item->m_UserData)->m_Maks), L"层通道");
		//props.push_back(通道遮罩);
	}
	else {

	}
	
	plane->f_构建属性部件(props);
}

void f_大纲视图_重构渲染物体属性栏(C_属性栏* plane, const std::set<S_Object*>& items) {
	std::vector<S_Props> props;

	
	if (items.size() == 1) {
		S_Object* item = *items.begin();

		S_渲染对象* renderOb = dynamic_cast<S_渲染对象*>(item);
		renderOb->m_物体->m_选中 = true;

		f_NodeCtx_set选中物体({renderOb->m_物体}, false);

		auto 场景通道 = f_alloc_FlagBitsUI8Prop(&renderOb->m_场景遮罩, u"场景通道");
		auto 物体通道 = f_alloc_FlagBitsUI8Prop(&renderOb->m_物体遮罩, u"物体通道");
		auto 物体遮罩 = f_alloc_FlagBitsEnumProp(&renderOb->m_物体光遮罩, *S_框架::g_物体遮罩类型项, u"光遮罩类型");

		props.push_back(场景通道);
		props.push_back(物体通道);
		props.push_back(物体遮罩);
	}

	plane->f_构建属性部件(props);
}

bool on_大纲视图_删除渲染世界(C_Widget* self, const std::u16string name, uint16 id) {
	
	C_大纲视图* view = dynamic_cast<C_大纲视图*>(f_ui_从菜单项取发起组件(self));

	auto obs = f_ui_树形框_取选择项(view->f_get子组件(0));
	for (auto& e : obs) {
		switch (e->m_Type) {
			case E_物体类型::t_渲染层: {
				
				//f_node_删除渲染层(item, e->m_Name);
				view->m_更新绘制属性 = true;
				break;
			}
			case E_物体类型::t_渲染物体: {
				e->m_父对象;
				f_OE_物体从渲染层移除(e->m_父对象, ((S_渲染对象**)&e), 1);
				//f_node_删除渲染层(item, e->m_Name);
				view->m_更新绘制属性 = true;
				break;
			}
		}
	}
	f_大纲视图_重构渲染层属性栏(view->m_属性栏, { });

	return false;
}




void f_大纲视图_添加对象(std::set<S_Object*>& items) {
	for (auto& e : C_大纲视图::g大纲视图) {
		f_ui_树形框_清楚选择项(e->f_get子组件(0));
	}

	std::set<C_Widget*> 树形框;
	for (auto& e : C_大纲视图::g大纲视图) {
		树形框.insert(e->f_get子组件(0));
	}

	for (auto& e : items) {
		f_ui_树形框_添加项(f_global_大纲数据(), e, 树形框);
	}
}

void f_大纲视图_删除对象(std::set<S_Object*>& items) {
	std::set<C_Widget*> 树形框;
	for (auto& e : C_大纲视图::g大纲视图) {
		树形框.insert(e->f_get子组件(0));
	}

	for (auto& e : items) {
		f_ui_树形框_删除项(f_global_大纲数据(), e, 树形框);
	}
}






